package org.pro.core.validateCode.sms;

import org.pro.core.validateCode.ValidateCode;
import org.pro.core.validateCode.processor.AbstractValidateCodeProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.context.request.ServletWebRequest;

/**
 * 短信验证码处理器
 * 
 * @author luoqiz
 *
 */
@Component("smsValidateCodeProcessor")
public class smsValidateCodeProcessor extends AbstractValidateCodeProcessor<ValidateCode> {

	@Autowired
	private SmsCodeSender smsCodeSender;
	
	@Override
	protected void send(ServletWebRequest servletWebRequest, ValidateCode validateCode) throws Exception {
		String mobile = ServletRequestUtils.getRequiredStringParameter(servletWebRequest.getRequest(), "mobile");
		smsCodeSender.send(mobile, validateCode.getSaveData());
	}

}
